Requirements of the File API
Learn the basic requirements to build a file service.
Introduction#
File or cloud storage services are gaining popularity because they offer cheaper, more reliable storage without the worry of manually managing and upgrading space. We can upload various media, such as photos, videos, documents, and software, to the cloud storage service. The media can be downloaded later when needed. Cloud storage services are designed to be reliable, so users can access their data as is when needed. The most popular cloud storage services today include Google Drive, Microsoft OneDrive, Amazon Drive, Dropbox, and MediaFire.
Let's now see what a file service looks like at an abstract level.
File service#
Cloud storage services work by transferring files from one computer system (client) to another (host), which is usually a more powerful computer system with a large storage capacity. From a client's perspective, uploading a file to remote storage may look like a simple API call, as shown below:
In reality, uploading files is a complex system of multiple services working together, some on the frontend and some on the backend. In this chapter, we will design an API service for storing files, learn about its main components, and discuss how these components affect our design decisions.
Requirements#
Before actually designing an API, we must first clearly define the desired functionality, security constraints, resiliency, performance expectations, and cost goals from a usage perspective. Below are some requirements for our hypothetical file API.
Functional requirements#
Upload: The API should allow users to securely upload files to remote storage.
Download: The API should allow users to download the uploaded files from remote storage.
Delete: The API should allow only the file owners to delete uploaded files from remote storage.
List: The API should allow file owners to list uploaded files in remote storage.
Non-functional requirements#
Reliability: Data should not be lost or corrupted during the transfer (during upload and download operations). Additionally, data must be stored persistently after a successful upload.
Security: The API should adopt appropriate security mechanisms to provide secure access to data.
Scalability: The API should be scalable to handle the increasing number of users and files.
Availability: The API should have high availability, allowing users to upload/download data on demand.
Low latency: The API should be able to upload/download data with low latency.
Prerequisites#
We recommend that you read about the following concepts before proceeding with this chapter, if you have not already.
How will we design a file API?#
File API Design Decisions: In this lesson, we will discuss the API architecture that works best for our API.
API model for File Service: In this lesson, we will design an API model and map the required features to endpoints.
File API Design Evaluation and Latency Budget: In this lesson, we will discuss how to achieve the non-functional requirements of our API.
Points to Ponder
Question 2
Should the support for multiple devices (mobile, tablet, laptop, etc.) be considered a separate functional requirement?
The support for multiple devices (phones, tablets, laptops, etc.) becomes API service agnostic when uploading or downloading files. Although the implementation details of the consuming application may vary, the actual content of the file remains the same. Therefore, support for different devices cannot be considered a separate functional requirement.
However, if we were building an API for a streaming service, then supporting different devices could be considered a separate functional requirement because different devices support the playback of different encodings, and we may have to transcode the data to the appropriate one for each device.
2 of 2
Search API Design Evaluation and Latency Budget
File API Design Decisions